<?php
/**
 * Num 记录和数字相关的类库
 * Created by PhpStorm .
 * User: 杜磊磊
 * Date: 2020/6/30
 * Time: 14:18
 */
declare(strict_types=1);
namespace app\common\lib;

class Num
{
    /**
     * 生成4位或6位数字验证码
     * @param int $len
     * @return int
     */
    public static function getCode(int $len = 4) : int
    {
        $code = rand(1000,9999);
        if ($len = 6){
            $code = rand(100000,999999);
        }
        return $code;
    }
}